<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>FLITr: examples/cuda_auto_contrast/pitched_2d_range.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">FLITr
   &#160;<span id="projectnumber">1.x</span>
   </div>
   <div id="projectbrief">Framework for Live Image Transformation.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('pitched__2d__range_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(11)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">pitched_2d_range.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="pitched__2d__range_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &lt;thrust/iterator/counting_iterator.h&gt;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &lt;thrust/iterator/transform_iterator.h&gt;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;thrust/iterator/permutation_iterator.h&gt;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;thrust/functional.h&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> InIterator&gt;</div>
<div class="line"><a name="l00010"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html">   10</a></span>&#160;<span class="keyword">class </span><a class="code" href="classpitched__2d__range.html">pitched_2d_range</a></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;{</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;  <span class="keyword">public</span>:</div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">   13</a></span>&#160;    <span class="keyword">typedef</span> <span class="keyword">typename</span> thrust::iterator_difference&lt;InIterator&gt;::type <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a>;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html">   15</a></span>&#160;    <span class="keyword">struct </span><a class="code" href="structpitched__2d__range_1_1pitch__functor.html">pitch_functor</a> : <span class="keyword">public</span> thrust::unary_function&lt;difference_type, difference_type&gt;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;    {</div>
<div class="line"><a name="l00017"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adf91817d084e4d9bb99bbd076fea7d2a">   17</a></span>&#160;        <span class="keyword">const</span> <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adf91817d084e4d9bb99bbd076fea7d2a">_width</a>;</div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html#ae4f0f7de2dfc28186e8db6c595bcf0b2">   18</a></span>&#160;        <span class="keyword">const</span> <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#ae4f0f7de2dfc28186e8db6c595bcf0b2">_padded_width</a>;</div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a3b70a08b4f80821412ee1dda3180d39c">   19</a></span>&#160;        <span class="keyword">const</span> <span class="keywordtype">bool</span> <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a3b70a08b4f80821412ee1dda3180d39c">_no_padding</a>;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a795fc1f325d74831902e9f56ada883e0">   21</a></span>&#160;        <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a795fc1f325d74831902e9f56ada883e0">pitch_functor</a>(<a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> width, <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> padded_width)</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;            : <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adf91817d084e4d9bb99bbd076fea7d2a">_width</a>(width), <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#ae4f0f7de2dfc28186e8db6c595bcf0b2">_padded_width</a>(padded_width), <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a3b70a08b4f80821412ee1dda3180d39c">_no_padding</a>(width == padded_width) {}</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;        __host__ __device__</div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adba75725b73347a19daa1eda6a914156">   25</a></span>&#160;        <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adba75725b73347a19daa1eda6a914156">operator()</a>(<span class="keyword">const</span> <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a>&amp; i)<span class="keyword"> const</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="keyword">        </span>{ </div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="structpitched__2d__range_1_1pitch__functor.html#a3b70a08b4f80821412ee1dda3180d39c">_no_padding</a>) <span class="keywordflow">return</span> i;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;            <span class="comment">// we need to convert from the unpadded index to the padded</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;            <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> row = i / <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adf91817d084e4d9bb99bbd076fea7d2a">_width</a>;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;            <span class="comment">// save a division versus i % _width</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;            <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> col = i - (row * <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#adf91817d084e4d9bb99bbd076fea7d2a">_width</a>);</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;            <span class="keywordflow">return</span> row * <a class="code" href="structpitched__2d__range_1_1pitch__functor.html#ae4f0f7de2dfc28186e8db6c595bcf0b2">_padded_width</a> + col;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        }</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    };</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#af1a3344cd32b28f62b5bdc07c5d7477c">   37</a></span>&#160;    <span class="keyword">typedef</span> <span class="keyword">typename</span> thrust::counting_iterator&lt;difference_type&gt; <a class="code" href="classpitched__2d__range.html#af1a3344cd32b28f62b5bdc07c5d7477c">CountingIterator</a>;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#ac73d5aedeac4136af64784c7ce45487c">   38</a></span>&#160;    <span class="keyword">typedef</span> <span class="keyword">typename</span> thrust::transform_iterator&lt;pitch_functor, CountingIterator&gt; <a class="code" href="classpitched__2d__range.html#ac73d5aedeac4136af64784c7ce45487c">TransformIterator</a>;</div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#ab7807ff001675b133ba0e37413919ef3">   39</a></span>&#160;    <span class="keyword">typedef</span> <span class="keyword">typename</span> thrust::permutation_iterator&lt;InIterator,TransformIterator&gt; <a class="code" href="classpitched__2d__range.html#ab7807ff001675b133ba0e37413919ef3">PermutationIterator</a>;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="comment">// type of the pitched_2d_range iterator</span></div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#ab53d7e4ff562453f6513528246b00007">   42</a></span>&#160;    <span class="keyword">typedef</span> <a class="code" href="classpitched__2d__range.html#ab7807ff001675b133ba0e37413919ef3">PermutationIterator</a> <a class="code" href="classpitched__2d__range.html#ab53d7e4ff562453f6513528246b00007">iterator</a>;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="comment">// construct our iterator for the range [first,last)</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a9d05e63b59a833e85485143d2a5b07c9">   45</a></span>&#160;    <a class="code" href="classpitched__2d__range.html#a9d05e63b59a833e85485143d2a5b07c9">pitched_2d_range</a>(InIterator first, InIterator last, <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> width, <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> padded_width)</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        : <a class="code" href="classpitched__2d__range.html#ace9ccae73e47ee15d7e7a0185479795e">_first</a>(first), <a class="code" href="classpitched__2d__range.html#a9f8352f41abf322e63762f94198dc199">_last</a>(last), <a class="code" href="classpitched__2d__range.html#a99a5e3da81a9df2413402d5fef0e0430">_width</a>(width), <a class="code" href="classpitched__2d__range.html#a9d60847f6e70cea607d9b1bec6a47c67">_padded_width</a>(padded_width) {}</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;   </div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#ac911da3a37271c8bfd56330032aa0c53">   48</a></span>&#160;    <a class="code" href="classpitched__2d__range.html#ab53d7e4ff562453f6513528246b00007">iterator</a> <a class="code" href="classpitched__2d__range.html#ac911da3a37271c8bfd56330032aa0c53">begin</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span></div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="keyword">    </span>{</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpitched__2d__range.html#ab7807ff001675b133ba0e37413919ef3">PermutationIterator</a>(<a class="code" href="classpitched__2d__range.html#ace9ccae73e47ee15d7e7a0185479795e">_first</a>, <a class="code" href="classpitched__2d__range.html#ac73d5aedeac4136af64784c7ce45487c">TransformIterator</a>(<a class="code" href="classpitched__2d__range.html#af1a3344cd32b28f62b5bdc07c5d7477c">CountingIterator</a>(0), <a class="code" href="structpitched__2d__range_1_1pitch__functor.html">pitch_functor</a>(<a class="code" href="classpitched__2d__range.html#a99a5e3da81a9df2413402d5fef0e0430">_width</a>, <a class="code" href="classpitched__2d__range.html#a9d60847f6e70cea607d9b1bec6a47c67">_padded_width</a>)));</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a5a7a596de1f1414010bbb7aeae509aac">   53</a></span>&#160;    <a class="code" href="classpitched__2d__range.html#ab53d7e4ff562453f6513528246b00007">iterator</a> <a class="code" href="classpitched__2d__range.html#a5a7a596de1f1414010bbb7aeae509aac">end</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="keyword">    </span>{</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpitched__2d__range.html#ac911da3a37271c8bfd56330032aa0c53">begin</a>() + ((<a class="code" href="classpitched__2d__range.html#a9f8352f41abf322e63762f94198dc199">_last</a> - <a class="code" href="classpitched__2d__range.html#ace9ccae73e47ee15d7e7a0185479795e">_first</a>)/<a class="code" href="classpitched__2d__range.html#a9d60847f6e70cea607d9b1bec6a47c67">_padded_width</a>)*<a class="code" href="classpitched__2d__range.html#a99a5e3da81a9df2413402d5fef0e0430">_width</a>;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    </div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a99a5e3da81a9df2413402d5fef0e0430">   60</a></span>&#160;    <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> <a class="code" href="classpitched__2d__range.html#a99a5e3da81a9df2413402d5fef0e0430">_width</a>;</div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a9d60847f6e70cea607d9b1bec6a47c67">   61</a></span>&#160;    <a class="code" href="classpitched__2d__range.html#a316d4d8ba405dc8f99833ba462400dd0">difference_type</a> <a class="code" href="classpitched__2d__range.html#a9d60847f6e70cea607d9b1bec6a47c67">_padded_width</a>;</div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#ace9ccae73e47ee15d7e7a0185479795e">   62</a></span>&#160;    InIterator <a class="code" href="classpitched__2d__range.html#ace9ccae73e47ee15d7e7a0185479795e">_first</a>;</div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="code" href="classpitched__2d__range.html#a9f8352f41abf322e63762f94198dc199">   63</a></span>&#160;    InIterator <a class="code" href="classpitched__2d__range.html#a9f8352f41abf322e63762f94198dc199">_last</a>;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;};</div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_cf9c97c292ca017bcde885f2be6e06e6.html">examples</a></li><li class="navelem"><a class="el" href="dir_b23609d1b432c4a4b23ccb3e701136c9.html">cuda_auto_contrast</a></li><li class="navelem"><a class="el" href="pitched__2d__range_8h.html">pitched_2d_range.h</a></li>
    <li class="footer">Generated on Thu Dec 6 2012 09:15:44 for FLITr by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.2 </li>
  </ul>
</div>
</body>
</html>
